package cn.clj1.func;

import cn.clj1.cell.CljCell;

import java.util.List;

/**
 * clojure 函数存在 函数符号表
 * */
public class CljFunc {
    // 参数列表
    private List<CljFuncParam> funcParams;
    // 函数的 body
    private CljCell funcBody;

    public CljFunc(List<CljFuncParam> funcParams, CljCell funcBody) {
        this.funcParams = funcParams;
        this.funcBody = funcBody;
    }

    public CljFunc() {}

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        if (funcParams != null)
        {
            for (int i = 0; i < funcParams.size(); i++)
            {
                CljFuncParam m = funcParams.get(i);
                if (i == funcParams.size() - 1)
                {
                    sb.append(m.toString());
                }
                else {
                    sb.append(m.toString() + " ");
                }
            }
        }
        sb.append("]");
        return sb.toString() + funcBody.toString();
    }

    public List<CljFuncParam> getFuncParams() {
        return funcParams;
    }

    public void setFuncParams(List<CljFuncParam> funcParams) {
        this.funcParams = funcParams;
    }

    public CljCell getFuncBody() {
        return funcBody;
    }

    public void setFuncBody(CljCell funcBody) {
        this.funcBody = funcBody;
    }
}

